using Circus.CodeEditor;
using Circus.Syntax;
using Circus.Syntax.CodeCompletion;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace Circus.CodeEditor.CodeCompletion
{
	[DesignTimeVisible(false), ToolboxItem(false)]
	public class CodeCompletionBox : CodeCompletionWindow, ICodeCompletionWindow
	{
		private const int tabPadding = 6;
		private int dropDownCount = EditConsts.DefaultDropDownCount;
		private CodeCompletionHint codeHint;
		private CodeCompletionEdit codeEdit;
		private Timer codeHintTimer;
		private bool sorted = true;
		private bool showTabs;
		private TabControl tabs;
		private Color codeCompletionBorderColor = EditConsts.DefaultCodeCompletionBorderColor;
		public event EventHandler SelectionChanged
		{
			add
			{
				this.ListBox.SelectedIndexChanged += value;
			}
			remove
			{
				this.ListBox.SelectedIndexChanged -= value;
			}
		}
		protected CompletionListBox ListBox
		{
			get
			{
				return (CompletionListBox)this.PopupControl;
			}
		}
		protected Timer CodeHintTimer
		{
			get
			{
				if (this.codeHintTimer == null)
				{
					this.codeHintTimer = new Timer();
					this.codeHintTimer.Enabled = false;
					this.codeHintTimer.Interval = EditConsts.DefaultHintDelay;
					this.codeHintTimer.Tick += new EventHandler(this.OnShowCodeHint);
				}
				return this.codeHintTimer;
			}
		}
		protected virtual TabControl Tabs
		{
			get
			{
				if (this.tabs == null)
				{
					this.tabs = new TabControl();
					this.tabs.Dock = DockStyle.Bottom;
					this.tabs.TabPages.Add(StringConsts.TabCommonText);
					this.tabs.TabPages.Add(StringConsts.TabAllText);
					this.tabs.Selected += new TabControlEventHandler(this.TabsSelected);
					this.tabs.LostFocus += new EventHandler(base.DoLostFocus);
					foreach (TabPage tabPage in this.tabs.TabPages)
					{
						tabPage.Enter += new EventHandler(this.TabEnter);
					}
					this.tabs.TabPages[0].Enter += new EventHandler(this.TabEnter);
					this.tabs.TabPages[1].Enter += new EventHandler(this.TabEnter);
					this.tabs.SizeMode = TabSizeMode.Fixed;
					this.tabs.Appearance = TabAppearance.FlatButtons;
					this.tabs.TabStop = false;
					this.tabs.Parent = this;
					this.tabs.Height = this.tabs.DisplayRectangle.Top;
					this.tabs.SendToBack();
				}
				return this.tabs;
			}
		}
		public bool ShowTabs
		{
			get
			{
				return this.showTabs;
			}
			set
			{
				if (this.showTabs != value)
				{
					this.showTabs = value;
					this.OnShowTabsChanged();
				}
			}
		}
		public Color CodeCompletionBorderColor
		{
			get
			{
				return this.codeCompletionBorderColor;
			}
			set
			{
				if (this.codeCompletionBorderColor != value)
				{
					this.codeCompletionBorderColor = value;
					this.OnCodeCompletionBorderColorChanged();
				}
			}
		}
		public virtual CodeCompletionColumn[] Columns
		{
			get
			{
				CodeCompletionColumn[] array = new CodeCompletionColumn[this.ListBox.ColumnCount];
				this.ListBox.Columns.CopyTo(array, 0);
				return array;
			}
		}
		public virtual CodeCompletionEdit CompletionEdit
		{
			get
			{
				if (this.codeEdit == null)
				{
					this.codeEdit = this.CreateCodeEdit();
					this.codeEdit.Edit.EditBox.KeyPress += new KeyPressEventHandler(this.CodeEditKeyPress);
					this.codeEdit.Edit.EditBox.KeyDown += new KeyEventHandler(this.CodeEditKeyDown);
					this.codeEdit.Edit.EditBox.LostFocus += new EventHandler(base.DoLostFocus);
					this.codeEdit.Edit.PathLabel.Click += new EventHandler(this.PathLabelClick);
					this.codeEdit.Disposed += new EventHandler(this.CodeEditDisposed);
				}
				return this.codeEdit;
			}
		}
		public virtual CodeCompletionHint CompletionHint
		{
			get
			{
				if (this.codeHint == null)
				{
					this.codeHint = this.CreateCodeHint(base.GetSyntaxEdit());
					this.codeHint.Enabled = false;
					this.codeHint.Provider = new QuickInfo();
					this.codeHint.CompletionFlags &= ~CodeCompletionFlags.CloseOnMouseLeave;
				}
				return this.codeHint;
			}
		}
		public virtual int DropDownCount
		{
			get
			{
				return this.dropDownCount;
			}
			set
			{
				if (this.dropDownCount != value)
				{
					this.dropDownCount = value;
					this.OnDropDownCountChanged();
				}
			}
		}
		public virtual bool Filtered
		{
			get
			{
				return this.ListBox.Filtered;
			}
			set
			{
				if (this.ListBox != null && this.ListBox.Filtered != value)
				{
					this.ListBox.Filtered = value;
					this.OnFilteredChanged();
				}
			}
		}
		public virtual string Filter
		{
			get
			{
				return this.ListBox.Filter;
			}
			set
			{
				if (this.ListBox != null && this.ListBox.Filter != value)
				{
					this.ListBox.Filter = value;
					this.OnFilterChanged();
				}
			}
		}
		public virtual bool Sorted
		{
			get
			{
				return this.sorted;
			}
			set
			{
				if (this.sorted != value || this.ListBox.Sorted != value)
				{
					this.sorted = value;
					this.ListBox.Sorted = value;
				}
			}
		}
		protected internal bool CaseSensitive
		{
			get
			{
				CodeEditor syntaxEdit = base.GetSyntaxEdit();
				return syntaxEdit != null && syntaxEdit.Lexer is SyntaxParser && ((SyntaxParser)syntaxEdit.Lexer).CaseSensitive;
			}
		}
		public override bool IsFocused
		{
			get
			{
				bool result;
				if (this.tabs != null)
				{
					if (this.tabs.Focused)
					{
						result = true;
						return result;
					}
					foreach (TabPage tabPage in this.tabs.TabPages)
					{
						if (tabPage.Focused)
						{
							result = true;
							return result;
						}
					}
				}
				result = base.IsFocused;
				return result;
			}
		}
		private bool IndexMatches(string text, int index, bool caseSensitive)
		{
			bool result;
			if (index >= 0 && index < this.ListBox.Items.Count)
			{
				string text2 = this.ListBox.Items[index].ToString();
				int num = text2.LastIndexOf('.');
				if (num >= 0)
				{
					text2 = text2.Substring(num + 1);
				}
				text2 = text2.Substring(0, Math.Min(text2.Length, text.Length));
				result = (string.Compare(text, text2, !caseSensitive) == 0);
			}
			else
			{
				result = false;
			}
			return result;
		}
		private int IndexOfString(string text, bool caseSensitive)
		{
			int result;
			if (this.IndexMatches(text, this.ListBox.SelectedIndex, caseSensitive))
			{
				result = this.ListBox.SelectedIndex;
			}
			else
			{
				for (int i = 0; i < this.ListBox.Items.Count; i++)
				{
					if (this.IndexMatches(text, i, caseSensitive))
					{
						result = i;
						return result;
					}
				}
				result = -1;
			}
			return result;
		}
		protected override void CodeEditDisposed()
		{
			if (base.Visible)
			{
				this.Close(false);
			}
			this.codeEdit = null;
		}
		protected override void UpdateAutoSize()
		{
			this.UpdateAutoSize(true, true);
		}
		protected virtual void UpdateAutoSize(bool horz, bool vert)
		{
			if (this.AutoSize)
			{
				int num;
				if (vert)
				{
					num = this.ListBox.ItemHeight * Math.Min(this.ListBox.Items.Count, (this.dropDownCount == 0) ? EditConsts.MaxDropDownCount : this.dropDownCount) + EditConsts.DefaultRowSeparator;
					if (this.showTabs && this.tabs != null)
					{
						num += this.tabs.Height;
					}
					num = Math.Max(num, EditConsts.DefaultMinListBoxHeight);
				}
				else
				{
					num = base.ClientRectangle.Width;
				}
				int num2;
				if (horz)
				{
					num2 = this.ListBox.ItemWidth + EditConsts.DefaultColumnSeparator * 4;
					if (this.ListBox.Images != null)
					{
						num2 += this.ListBox.Images.ImageSize.Width + EditConsts.DefaultColumnSeparator;
					}
					num2 += OSUtils.GetScrollSize(false);
					num2 = Math.Max(num2, EditConsts.DefaultMinListBoxWidth);
				}
				else
				{
					num2 = base.ClientRectangle.Width;
				}
				base.ClientSize = new Size(num2, num);
			}
		}
		protected override void DoShow(Point position)
		{
			this.Filter = string.Empty;
			this.ListBox.Images = ((this.Provider != null && this.Provider.Images != null) ? this.Provider.Images : this.Images);
			if (this.showTabs && this.tabs != null)
			{
				int num = (this.Provider.Count == 0 || this.Provider.SelIndex >= 0) ? 1 : this.tabs.SelectedIndex;
				if (this.tabs.SelectedIndex != num)
				{
					this.tabs.SelectedIndex = num;
				}
				else
				{
					this.OnTabsSelected(num);
				}
			}
			if (this.Provider != null && this.Provider.SelIndex >= 0)
			{
				if (this.ListBox.GetIndex(this.Provider.SelIndex) == this.Provider.SelIndex)
				{
					if (this.Provider.SelIndex < this.ListBox.Items.Count)
					{
						this.ListBox.SelectedIndex = this.Provider.SelIndex;
					}
				}
				else
				{
					for (int i = 0; i < this.ListBox.Items.Count; i++)
					{
						if (this.ListBox.GetIndex(i) == this.Provider.SelIndex)
						{
							this.ListBox.SelectedIndex = i;
							break;
						}
					}
				}
			}
			else
			{
				if (this.Provider != null)
				{
					this.PerformSearch();
				}
				else
				{
					this.ListBox.SelectedIndex = -1;
				}
			}
			this.ListBox.FocusMode = (this.Provider != null && this.Provider.FocusMode);
			this.showing = true;
			try
			{
				this.ShowCodeEdit(ref position);
				this.DoShowCodeHint();
				base.DoShow(position);
				if (this.codeEdit != null && this.codeEdit.Visible)
				{
					this.codeEdit.Focus();
				}
			}
			finally
			{
				this.showing = false;
			}
		}
		protected override Control CreatePopupControl()
		{
			ListBox listBox = new CompletionListBox();
			listBox.SelectedIndexChanged += new EventHandler(this.DoSelectionChanged);
			listBox.MouseWheel += new MouseEventHandler(this.DoMouseWheel);
			listBox.KeyDown += new KeyEventHandler(this.DoKeyDown);
			return listBox;
		}
		protected override void DoHide()
		{
			base.DoHide();
			this.HideCodeHint();
			this.HideCodeEdit();
		}
		protected virtual void HideCodeHint()
		{
			if (this.codeHint != null)
			{
				this.codeHint.Close(false);
			}
		}
		protected virtual void HideCodeEdit()
		{
			if (this.codeEdit != null)
			{
				this.codeEdit.Close(false);
			}
		}
		protected virtual void DoShowCodeHint()
		{
			this.HideCodeHint();
			this.CodeHintTimer.Enabled = false;
			this.CodeHintTimer.Enabled = true;
		}
		protected virtual bool UpdateCodeEdit(ref Point position)
		{
			bool result;
			if (this.Provider != null && this.Provider.EditField != null && this.Provider.EditField != string.Empty)
			{
				CodeCompletionEdit completionEdit = this.CompletionEdit;
				completionEdit.Provider = this.Provider;
				completionEdit.EditField = this.Provider.EditField;
				completionEdit.EditPath = this.Provider.EditPath;
				completionEdit.EditText = string.Empty;
				position.X = completionEdit.Location.X + completionEdit.Edit.EditBox.Left;
				result = true;
			}
			else
			{
				this.HideCodeEdit();
				result = false;
			}
			return result;
		}
		protected virtual void ShowCodeEdit(ref Point position)
		{
			if (this.Provider != null && this.Provider.EditField != null && this.Provider.EditField != string.Empty)
			{
				CodeCompletionEdit completionEdit = this.CompletionEdit;
				completionEdit.PopupAt(new Point(position.X, position.Y - completionEdit.Height));
				this.UpdateCodeEdit(ref position);
			}
		}
		protected virtual void OnShowCodeHint(object sender, EventArgs e)
		{
			this.ShowCodeHint(this.ListBox.GetIndex());
			this.CodeHintTimer.Enabled = false;
		}
		protected virtual void ShowCodeHint(int index)
		{
			if (base.Visible && index >= 0 && this.Provider != null && this.Provider.ShowDescriptions && index < this.Provider.Count)
			{
				string text = this.Provider.Descriptions[index];
				if (text != string.Empty)
				{
					CodeCompletionHint completionHint = this.CompletionHint;
					ICodeCompletionProvider provider = completionHint.Provider;
					provider.UseHtmlFormatting = this.Provider.UseHtmlFormatting;
					completionHint.Provider = null;
					((QuickInfo)provider).Text = text;
					completionHint.Provider = provider;
					completionHint.ResetContent();
					Point position = base.PointToScreen(new Point(base.Width, (this.ListBox.SelectedIndex - this.ListBox.TopIndex) * this.ListBox.ItemHeight));
					completionHint.EnsureVisible(ref position);
					Rectangle rectangle = new Rectangle(position.X, position.Y, completionHint.Size.Width, completionHint.Size.Height);
					rectangle.Intersect(base.Bounds);
					if (!rectangle.IsEmpty)
					{
						position.X = base.Left - completionHint.Size.Width;
					}
					completionHint.PopupAt(position);
				}
			}
			else
			{
				this.HideCodeHint();
			}
		}
		protected virtual void DoSelectionChanged(object sender, EventArgs e)
		{
			this.DoShowCodeHint();
		}
		protected override int GetSelectedIndex()
		{
			return this.ListBox.GetIndex();
		}
		protected virtual void DoKeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Space && (this.CompletionFlags & CodeCompletionFlags.AcceptOnDelimiter) != CodeCompletionFlags.None)
			{
				e.Handled = true;
			}
		}
		protected virtual void DoMouseWheel(object sender, MouseEventArgs e)
		{
			this.HideCodeHint();
		}
		protected virtual void CodeEditKeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\b' && sender is TextBox && ((TextBox)sender).SelectionStart == 0)
			{
				if (this.Provider.GetParent() != null)
				{
					this.Provider = this.Provider.GetParent();
					this.ListBox.SelectedIndex = this.Provider.SelIndex;
				}
				e.Handled = true;
			}
		}
		protected virtual void CodeEditDisposed(object sender, EventArgs e)
		{
			if (base.Visible)
			{
				this.Close(false);
			}
			this.codeEdit = null;
		}
		protected virtual void CodeEditKeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyData == Keys.F1)
			{
				HelpEventArgs hevent = new HelpEventArgs(Point.Empty);
				this.OnHelpRequested(hevent);
			}
		}
		protected virtual void PathLabelClick(object sender, EventArgs e)
		{
			if (this.Provider.GetParent() != null)
			{
				this.Provider = this.Provider.GetParent();
				this.ListBox.SelectedIndex = this.Provider.SelIndex;
			}
		}
		protected override void SetProvider(ICodeCompletionProvider provider)
		{
			this.ListBox.Sorted = (this.sorted && provider != null && provider.Count > 1);
			this.ListBox.Provider = provider;
			this.ListBox.Images = ((provider != null && provider.Images != null) ? provider.Images : this.Images);
			this.HideCodeHint();
			Point location = base.Location;
			if (this.UpdateCodeEdit(ref location))
			{
				base.Location = location;
			}
		}
		protected virtual CodeCompletionHint CreateCodeHint(CodeEditor edit)
		{
			return new CodeCompletionHint(base.GetSyntaxEdit());
		}
		protected virtual CodeCompletionEdit CreateCodeEdit()
		{
			return new CodeCompletionEdit(base.GetSyntaxEdit(), this);
		}
		protected void DoUpdateSize(object sender, EventArgs e)
		{
			this.UpdateAutoSize();
		}
		protected virtual void OnDropDownCountChanged()
		{
			this.UpdateAutoSize(false, true);
		}
		protected virtual void OnFilteredChanged()
		{
		}
		protected virtual void OnFilterChanged()
		{
		}
		protected virtual void TabsSelected(object sender, TabControlEventArgs e)
		{
			this.OnTabsSelected(e.TabPageIndex);
		}
		protected virtual void TabEnter(object sender, EventArgs e)
		{
			if (this.PopupControl.CanFocus)
			{
				this.PopupControl.Focus();
			}
		}
		protected virtual void OnTabsSelected(int index)
		{
			int num = (index == 0) ? 0 : -1;
			if (this.ListBox.Priority != num)
			{
				this.ListBox.Priority = num;
			}
			else
			{
				this.ListBox.ResetContent(0);
			}
		}
		protected virtual void AdjustTabWidth()
		{
			if (this.tabs != null && this.tabs.TabCount > 0)
			{
				this.tabs.ItemSize = new Size(base.ClientRectangle.Width / this.tabs.TabCount - 6 * this.tabs.TabCount, this.tabs.ItemSize.Height);
			}
		}
		protected override void OnResize(EventArgs e)
		{
			base.OnResize(e);
			this.AdjustTabWidth();
		}
		protected virtual void OnShowTabsChanged()
		{
			if (this.showTabs)
			{
				this.Tabs.TabIndex = 0;
				this.AdjustTabWidth();
				this.OnTabsSelected(0);
			}
			else
			{
				if (this.tabs != null)
				{
					this.tabs.Visible = false;
				}
			}
		}
		protected virtual void OnCodeCompletionBorderColorChanged()
		{
		}
		protected override void DoProcessKeyMessage(ref Message m)
		{
			if (this.codeEdit == null || !this.codeEdit.Visible)
			{
				base.DoProcessKeyMessage(ref m);
			}
		}
		protected override bool ProcessKeyPreview(ref Message m)
		{
			bool result;
			if (m.Msg == 256 || m.Msg == 260)
			{
				Keys keys = (Keys)(m.WParam.ToInt32() & 65535);
				if (((keys == Keys.Tab && (this.CompletionFlags & CodeCompletionFlags.AcceptOnTab) != CodeCompletionFlags.None) || (keys == Keys.Space && (this.CompletionFlags & CodeCompletionFlags.AcceptOnSpace) != CodeCompletionFlags.None)) && (Control.ModifierKeys == Keys.None || Control.ModifierKeys == Keys.Shift))
				{
					this.Close(true, (keys == Keys.Tab) ? '\t' : ' ');
					result = true;
					return result;
				}
				if (Array.IndexOf<Keys>(this.ListBox.NavKeys, keys) >= 0)
				{
					result = false;
					return result;
				}
			}
			if (this.OnProcessKeyPreview(ref m))
			{
				result = true;
			}
			else
			{
				CodeEditor syntaxEdit = base.GetSyntaxEdit();
				if (m.Msg == 258 && syntaxEdit != null && (Control.ModifierKeys == Keys.None || Control.ModifierKeys == Keys.Shift))
				{
					char c = (char)m.WParam.ToInt32();
					if ((this.CompletionFlags & CodeCompletionFlags.AcceptOnDelimiter) != CodeCompletionFlags.None && c > ' ' && syntaxEdit.Lines.IsDelimiter(c))
					{
						this.Close(true, c);
					}
					if (this.codeEdit != null && this.codeEdit.Visible && !this.codeEdit.Edit.EditBox.Focused)
					{
						OSUtils.SendMessage(this.codeEdit.Edit.EditBox.Handle, m.Msg, m.WParam, m.LParam);
					}
				}
				result = base.ProcessKeyPreview(ref m);
			}
			return result;
		}
		protected override void WndProc(ref Message m)
		{
			int msg = m.Msg;
			if (msg != 133)
			{
				base.WndProc(ref m);
			}
			else
			{
				base.WndProc(ref m);
				IntPtr windowDC = OSUtils.GetWindowDC(base.Handle);
				try
				{
					Graphics graphics = Graphics.FromHdc(windowDC);
					Pen pen = new Pen(this.codeCompletionBorderColor);
					try
					{
						graphics.DrawRectangle(pen, 0, 0, base.Width - 1, base.Height - 1);
					}
					finally
					{
						pen.Dispose();
						graphics.Dispose();
					}
				}
				finally
				{
					OSUtils.ReleaseDC(base.Handle, windowDC);
				}
			}
		}
		public CodeCompletionBox(CodeEditor owner) : base(owner)
		{
			this.CompletionFlags &= ~CodeCompletionFlags.CloseOnMouseLeave;
			this.Sizeable = true;
			this.UpdateAutoSize(false, true);
			CompletionListBox expr_4D = this.ListBox;
			expr_4D.UpdateSize = (EventHandler)Delegate.Combine(expr_4D.UpdateSize, new EventHandler(this.DoUpdateSize));
			this.ListBox.TabStop = false;
			this.Font = new Font(EditConsts.DefaultCodeCompletionFont, EditConsts.DefaultCodeCompletionFontSize);
			base.FormBorderStyle = FormBorderStyle.FixedToolWindow;
		}
		public override void ResetContent()
		{
			this.ListBox.ResetContent();
		}
		public override void ResetSizeable()
		{
			this.Sizeable = true;
		}
		public virtual void ClearColumns()
		{
			this.ListBox.ClearColumns();
		}
		public virtual CodeCompletionColumn AddColumn()
		{
			return this.ListBox.AddColumn();
		}
		public virtual CodeCompletionColumn InsertColumn(int index)
		{
			return this.ListBox.InsertColumn(index);
		}
		public virtual void RemoveColumnAt(int index)
		{
			this.ListBox.RemoveColumnAt(index);
		}
		public virtual void ResetDropDownCount()
		{
			this.DropDownCount = EditConsts.DefaultDropDownCount;
		}
		public virtual void ResetCodeCompletionBorderColor()
		{
			this.CodeCompletionBorderColor = EditConsts.DefaultCodeCompletionBorderColor;
		}
		public override void PopupAt(Point position)
		{
			if (this.Provider != null && this.Provider.SelIndex < 0 && (this.CompletionFlags & CodeCompletionFlags.ForceSelection) != CodeCompletionFlags.None)
			{
				this.Provider.SelIndex = 0;
			}
			base.PopupAt(position);
		}
		public override bool ContainsControl(Control control)
		{
			return base.ContainsControl(control) || (this.codeEdit != null && (control == this.codeEdit || control == this.codeEdit.Edit || control == this.codeEdit.Edit.EditBox || control == this.codeEdit.Edit.PathLabel)) || (this.tabs != null && (control == this.tabs || control.Parent == this.tabs));
		}
		public override bool PerformSearch()
		{
			bool result;
			if (this.Provider == null)
			{
				result = false;
			}
			else
			{
				string text = null;
				if (this.codeEdit != null && this.codeEdit.Visible)
				{
					text = this.codeEdit.EditText;
				}
				else
				{
					CodeEditor syntaxEdit = base.GetSyntaxEdit();
					if (syntaxEdit != null)
					{
						Point position = syntaxEdit.Position;
						if (position.Y == this.StartPos.Y && position.X > this.StartPos.X)
						{
							text = syntaxEdit.Lines[position.Y];
							if (this.StartPos.X < text.Length)
							{
								text = ((position.X < text.Length) ? text.Substring(this.StartPos.X, position.X - this.StartPos.X) : text.Substring(this.StartPos.X));
							}
						}
					}
				}
				if (text != null)
				{
					if (this.Filtered)
					{
						this.Filter = text.Trim();
					}
					else
					{
						bool caseSensitive = this.CaseSensitive;
						int num = this.IndexOfString(text, caseSensitive);
						if (caseSensitive && num < 0)
						{
							num = this.IndexOfString(text, false);
						}
						if (num >= 0)
						{
							this.ListBox.SelectedIndex = num;
						}
						else
						{
							this.ListBox.SelectedIndex = -1;
						}
					}
				}
				else
				{
					if (this.Filtered)
					{
						this.Filter = string.Empty;
					}
					else
					{
						this.ListBox.SelectedIndex = -1;
					}
				}
				result = (text != null);
			}
			return result;
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (this.codeHintTimer != null)
				{
					this.codeHintTimer.Tick -= new EventHandler(this.OnShowCodeHint);
					this.codeHintTimer.Dispose();
					this.codeHintTimer = null;
				}
				if (this.codeHint != null)
				{
					((IDisposable)this.codeHint).Dispose();
					this.codeHint = null;
				}
				if (this.codeEdit != null)
				{
					this.codeEdit.Disposed -= new EventHandler(this.CodeEditDisposed);
					this.codeEdit.Edit.EditBox.KeyPress -= new KeyPressEventHandler(this.CodeEditKeyPress);
					this.codeEdit.Edit.EditBox.KeyDown -= new KeyEventHandler(this.CodeEditKeyDown);
					this.codeEdit.Edit.EditBox.LostFocus -= new EventHandler(base.DoLostFocus);
					this.codeEdit.Edit.PathLabel.Click -= new EventHandler(this.PathLabelClick);
					((IDisposable)this.codeEdit).Dispose();
					this.codeEdit = null;
				}
				CompletionListBox listBox = this.ListBox;
				if (listBox != null)
				{
					listBox.SelectedIndexChanged -= new EventHandler(this.DoSelectionChanged);
					listBox.MouseWheel -= new MouseEventHandler(this.DoMouseWheel);
					listBox.KeyDown -= new KeyEventHandler(this.DoKeyDown);
				}
			}
			base.Dispose(disposing);
		}
	   
	}
}
